<?php
include('libary/init_index.php');
checkvar('key');
echo '<p id="searchresults">';	
		if(isset($_POST['key'])){
			$key=$_POST['key'];
			if(strlen($key) >0){	
        $cmd="SELECT * FROM `select` WHERE select_tag LIKE '%$key%' LIMIT 0,3";
				$excute=mysql_query($cmd);
				if (mysql_num_rows($excute)>0)
				{
				echo '<span class="category">NGHỆ SĨ</span>';
					while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
					{
						echo '<a href="http://beta.cailuongso.com/artist/'.isolink($info['select_art']).'/'.$info['select_hash'].'.html">
						<img src="'.$info['select_img'].'">';
						echo $info['select_art'].'<br/>';
						echo '</a>';
					}
				}
				//-------------------------
				$cmd="SELECT * FROM `album` WHERE album_tag LIKE '%$key%' LIMIT 0,3";
				$excute=mysql_query($cmd);
				if (mysql_num_rows($excute)>0)
				{
				echo '<span class="category">ALBUM</span>';			
					while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
					{
						echo '<a href="http://beta.cailuongso.com/album/'.isolink($info['album_name']).'/'.$info['album_hash'].'.html">
						<img src="'.$info['album_link'].'">';
						echo $info['album_name'].'<br/>';
						echo '</a>';
					}
				}
				//--------------------------
				$cmd="SELECT * FROM  `media` WHERE (media_link LIKE '%youtu%') AND (`media_tag` LIKE '%$key%') LIMIT 0,3";
				$excute=mysql_query($cmd);
				if (mysql_num_rows($excute)>0)
				{
				echo '<span class="category">Video/</span>';
					while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
					{
						echo '<a href="http://beta.cailuongso.com/video/'.isolink($info['media_name']).'/'.$info['media_hash'].'.html">
						<img src="'.$info['media_img'].'">';
						echo $info['media_name'].'<br/>';
						echo '</a>';
					}
				}
				//---------------------------
				$cmd="SELECT * FROM  `media` WHERE (media_link LIKE '%mp3%') AND (`media_tag` LIKE '%$key%') LIMIT 0,3";
				$excute=mysql_query($cmd);
				if (mysql_num_rows($excute)>0)
				{
				echo '<span class="category">AUDIO</span>';
					while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
					{
						echo '<a href="http://beta.cailuongso.com/audio/'.isolink($info['media_name']).'/'.$info['media_hash'].'.html">';
						echo $info['media_name'].'<br/>';
						echo '</a>';
					}
				}
			} 
		}
?>
</p>